package com.xintouyun.medicine.service.impl;

import java.util.List;

import com.xintoucloud.jdbcutil.JdbcUtil;
import com.xintouyun.medicine.dao.GoodsDao;
import com.xintouyun.medicine.entity.Goods;
import com.xintouyun.medicine.service.IndexGoodsShowService;

public class IndexGoodsShowServiceImpl implements IndexGoodsShowService{
    GoodsDao goodsDao = new GoodsDao();
	@Override
	public List<Goods> indexShowGoods(int indexId) {
		try {
			List<Goods> showGoods = goodsDao.list("select gid,gname,fileName,price from m_goods where index_id=? and state!=2",indexId);
			return showGoods;
		} finally {
			JdbcUtil.closeConnection();
		}
	}
	
	@Override
	public List<Goods> SearchGoods(int typeId) {
        try {
			List<Goods> searchGoods = goodsDao.list("select gid,gname,factory,fileName,price,minorder from m_goods where type_id=? and state!=2", typeId);
			return searchGoods;
		} finally {
			JdbcUtil.closeConnection();
		}
	}

	@Override
	public List<Goods> keywordsGoods(String keywords,int pageIndex,int pageSize) {
		try {
			String page = " limit " + (pageIndex-1)*pageSize + "," + pageSize;
			List<Goods> keywordsGoods = goodsDao.list("select * from m_goods where gname like ? and state!=2"+page, "%"+keywords+"%");
			return keywordsGoods;
		} finally {
			JdbcUtil.closeConnection();
		}
	}

	@Override
	public List<Goods> parentTidGoods(String sql) {
		try {
			List<Goods> parentTidGoods = goodsDao.list(sql);
			return parentTidGoods;
		} finally {
			JdbcUtil.closeConnection();
		}
	}
	
	
}
